package com.kopipi.translation;

import com.kopipi.cache.HalfSymetryCache;
import com.kopipi.exception.TranslationException;
import com.kopipi.utils.ReflectUtils;

public class Kopipi {
	
	public static <T> T translate(Object source, T target) throws TranslationException {
		checkHalfSymetry(source.getClass(), target.getClass());
		ReflectUtils.translate(source, target);
		return target;
	}
	
	private static void checkHalfSymetry(Class<?> source, Class<?> target) {
		if (HalfSymetryCache.contains(source, target)) {
			return;
		}
		ReflectUtils.checkHalfSymetry(source, target);
		HalfSymetryCache.add(source, target);
	}

}
